package com.qjz.diancan.mapper;


import com.qjz.diancan.model.entity.Dish;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author zhu
 * @since 2024-02-14
 */
@Mapper
public interface DishMapper {

    @Select("select * from dish where id = #{id}")
    Dish getDishData(Integer id);

    @Insert("insert into dish(name,price,category_id,status,image,create_time) values(#{name},#{price},#{categoryId},#{status},#{image},now())")
    void addDishData(Dish dish);

    @Update("update dish set status = #{state} where id = #{id}")
    void updateDishDataState(@Param("id") Integer id, @Param("state") Integer state);

    List<Dish> findByPage(@Param("name") String name, @Param("categoryId") Integer categoryId, @Param("status") Integer status);

    @Update("update dish set name = #{name},price = #{price},category_id = #{categoryId},image = #{image} where id = #{id}")
    void updateDishData(Dish dish);
}
